<template>
	<view class="page">
		<OrgMine  v-show="userInfo.userType == enums['账号类型']['机构']" ref="orgRef"></OrgMine>
		<UserMine   v-show="userInfo.userType == enums['账号类型']['用户']" ref="userRef"></UserMine>
	</view>
</template>

<script>
	import {
		HTTP_SERVER_URL,
		STATUS_CODE
	} from '../../config/index.js';
	import UserMine from './userMine.vue';
	import OrgMine from './orgMine.vue';
	export default {
		components:{
			UserMine,
			OrgMine
		},
		data() {   
			return {
				userInfo:this.$store.getters.getUser,
				enums: this.$enums,
				user:null,
				infoCounts:null
			}
		},
		onLoad() {
			//获取用户code
			wx.login({
				provider:'weixin',
				success: (res) => {
				
					this.code=res.code
					// console.log("code",this.code)
					uni.request({
						url:HTTP_SERVER_URL+'/aged/user/appletsLogin',
									method:"POST",
									data:{
										code:this.code
									},
									success:(res)=>{
										this.openId=res.data.data.openId
										this.sessionKey=res.data.data.sessionKey
										// console.log('openid',this.openId)
									},
									fail:(res)=>{
										// console.log('失败失败',res)
									}
					})
					
				}
			})
		},
		onShow() {
			this.userInfo=uni.getStorageSync('open')
			console.log('mine页面的用户信息',this.userInfo)
			setTimeout(()=>{
				if(this.userInfo.userType == this.enums['账号类型']['机构']) {
					this.$refs.orgRef.getdata();
					this.$refs.orgRef.truemess();
				}
			},100)
			// this.getUserData()
			// this.$refs.orgRef.getdata()
			// if(this.userInfo.userType==1){
			// 	this.$refs.orgRef.truemess()
			// }else{
			// 	this.$refs.userRef.Truemess()
			// }
			
		},
		methods: {
			getuserinfo:function(e){
				// console.log(e.detail.userInfo.avatarUrl)
				// console.log(e.detail.userInfo.nickName)
				this.huoqu=1
				this.img=e.detail.userInfo.avatarUrl
				this.name=e.detail.userInfo.nickName
			},
			getUserData(){
				setTimeout( () => {
					if(this.userInfo.userType == this.enums['账号类型']['机构']) {
						this.$refs.orgRef.getData();
					}
				}, 100) 
			},
		}
	}
</script>

<style lang="stylus">
	
</style>
